using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace TidhiGanitam.DataModel
{
    public class PanchanzyamuRoutineItem
    {
        private int m_Year;
        DateTime m_Date;
        private int m_SNo;
        ArrayList m_RaviRoutines;
        ArrayList m_ChandraRoutines;
        ArrayList m_DinamuRoutines;
        YearDetails m_CurrentYearDetails;

        TidhiRoutineItem m_TidhiRoutineItem;
        KaranamuRoutineItem m_KaranamuRoutineItem;
        NakshatramuRoutineItem m_NakshatramuRoutineItem;
        YogamuRoutineItem m_YogamuRoutineItem;
        VarjyamuRoutineItem m_VarjyamuRoutineItem;
        AmrutaGhadiyaluRoutineItem m_AmrutaGhadiyaluRoutineItem;
        DurmuhurtamuRoutineItem m_DurmuhurtaaluRoutineItem;
        ArkahaRoutineItem m_ArkahaRoutineItem;
        BhuktiRoutineItem m_BhuktiRoutineItem;

    
        public int Bhagam
        {
            get { return m_SNo; }
        }
        public DateTime Date
        {
            get { return m_Date; }
        }

        public TidhiRoutineItem TidhiRoutine
        {
            get
            { return m_TidhiRoutineItem; }
            set
            { m_TidhiRoutineItem = value; }
        }
        public KaranamuRoutineItem KaranamuRoutine
        {
            get
            { return m_KaranamuRoutineItem; }
            set
            { m_KaranamuRoutineItem = value; }
        }
        public NakshatramuRoutineItem NakshatramuRoutine
        {
            get
            { return m_NakshatramuRoutineItem; }
            set
            { m_NakshatramuRoutineItem = value; }
        }

        public YogamuRoutineItem YogamuRoutine
        {
            get
            { return m_YogamuRoutineItem; }
            set
            {
                m_YogamuRoutineItem = value;
            }
        }
        public VarjyamuRoutineItem VarjyamuRoutine
        {
            get
            { return m_VarjyamuRoutineItem; }
            set
            { m_VarjyamuRoutineItem = value; }
        }
        public AmrutaGhadiyaluRoutineItem AmrutaGhadiyalu
        {
            get
            { return m_AmrutaGhadiyaluRoutineItem; }
            set
            { m_AmrutaGhadiyaluRoutineItem = value; }
        }
        public DurmuhurtamuRoutineItem Durmuhurtaalu
        {
            get
            { return m_DurmuhurtaaluRoutineItem; }
            set
            { m_DurmuhurtaaluRoutineItem = value; }
        }
        public ArkahaRoutineItem Arkaha
        {
            get
            { return m_ArkahaRoutineItem; }
            set
            { m_ArkahaRoutineItem = value; }
        }
        public BhuktiRoutineItem Bhukti
        {
            get
            { return m_BhuktiRoutineItem; }
            set
            { m_BhuktiRoutineItem = value; }
        }
        public PanchanzyamuRoutineItem(int SNo, int Year, DateTime Date, ArrayList RaviRoutines, 
            ArrayList ChandraRoutines, ArrayList DinamuRoutines, YearDetails CurrentYearDetails)
        {
            m_SNo = SNo;
            m_Year = Year;
            m_Date = Date;
            m_RaviRoutines = RaviRoutines;
            m_ChandraRoutines = ChandraRoutines;
            m_DinamuRoutines = DinamuRoutines;
            m_CurrentYearDetails = new YearDetails(CurrentYearDetails);
        }
        public void Calculate(PanchanzyamuRoutineItem PreviousPanchanzyamuRoutine, ref double Direction)
        {
            TidhiRoutineItem PreviousTidhiRoutine = PreviousPanchanzyamuRoutine.TidhiRoutine;
            KaranamuRoutineItem PreviousKaranamuRoutine = PreviousPanchanzyamuRoutine.KaranamuRoutine;
            NakshatramuRoutineItem PreviousNakshatramuRoutine = PreviousPanchanzyamuRoutine.NakshatramuRoutine;
            YogamuRoutineItem PreviousYogamuRoutine = PreviousPanchanzyamuRoutine.YogamuRoutine;
            DinamuRoutineItem PreviousDinamu = (DinamuRoutineItem)m_DinamuRoutines[PreviousPanchanzyamuRoutine.Bhagam];
            RaviRoutineItem PreviousRavi = (RaviRoutineItem)m_RaviRoutines[PreviousPanchanzyamuRoutine.Bhagam];
            BhuktiRoutineItem PreviousBhuktiRoutine = (BhuktiRoutineItem)PreviousPanchanzyamuRoutine.Bhukti;

            m_TidhiRoutineItem = new TidhiRoutineItem(m_SNo, m_Year, m_Date, PreviousTidhiRoutine.CurrentTidhi,
                PreviousTidhiRoutine.CurrentMasamu, PreviousTidhiRoutine.PreviousTidhiState,
                m_RaviRoutines, m_ChandraRoutines, m_DinamuRoutines, m_CurrentYearDetails);
            m_TidhiRoutineItem.Calculate(false, PreviousTidhiRoutine, PreviousDinamu);

            m_KaranamuRoutineItem = new KaranamuRoutineItem(m_TidhiRoutineItem, m_TidhiRoutineItem.KaranamuTidhi);
            m_KaranamuRoutineItem.Calculate(PreviousDinamu, PreviousTidhiRoutine, PreviousKaranamuRoutine);

            m_NakshatramuRoutineItem = new NakshatramuRoutineItem(m_SNo, m_Year, m_Date, PreviousNakshatramuRoutine.CurrentNakshatramu,
                PreviousNakshatramuRoutine.PreviousNakshatramuState, m_RaviRoutines, m_ChandraRoutines, m_DinamuRoutines);
            m_NakshatramuRoutineItem.Calculate(false, PreviousNakshatramuRoutine, PreviousDinamu);

            m_YogamuRoutineItem = new YogamuRoutineItem(m_SNo, m_Year, m_Date, PreviousYogamuRoutine.CurrentYogamu,
                PreviousYogamuRoutine.PreviousYogamuState, m_RaviRoutines, m_ChandraRoutines, m_DinamuRoutines);
            m_YogamuRoutineItem.Calculate(false, PreviousYogamuRoutine, PreviousDinamu);

            m_VarjyamuRoutineItem = new VarjyamuRoutineItem(m_SNo, m_Year, m_Date, m_NakshatramuRoutineItem, (DinamuRoutineItem)m_DinamuRoutines[m_SNo]);
            m_VarjyamuRoutineItem.Calculate(PreviousDinamu, PreviousNakshatramuRoutine, PreviousPanchanzyamuRoutine.VarjyamuRoutine);

            m_AmrutaGhadiyaluRoutineItem = new AmrutaGhadiyaluRoutineItem(m_SNo, m_Year, m_Date, m_NakshatramuRoutineItem, (DinamuRoutineItem)m_DinamuRoutines[m_SNo]);
            m_AmrutaGhadiyaluRoutineItem.Calculate(PreviousDinamu, PreviousNakshatramuRoutine, PreviousPanchanzyamuRoutine.AmrutaGhadiyalu);

            m_DurmuhurtaaluRoutineItem = new DurmuhurtamuRoutineItem(m_SNo, m_Year, m_Date, (DinamuRoutineItem)m_DinamuRoutines[m_SNo]);
            m_DurmuhurtaaluRoutineItem.Calculate();

            m_ArkahaRoutineItem = new ArkahaRoutineItem(m_SNo, m_Year, m_Date, (RaviRoutineItem)m_RaviRoutines[m_SNo], (DinamuRoutineItem)m_DinamuRoutines[m_SNo]);
            m_ArkahaRoutineItem.Calculate(PreviousRavi, ref Direction);

            m_BhuktiRoutineItem = new BhuktiRoutineItem(m_SNo, m_Year, m_Date, (DinamuRoutineItem)m_DinamuRoutines[m_SNo], (RaviRoutineItem)m_RaviRoutines[m_SNo]);
            m_BhuktiRoutineItem.Calculate(PreviousBhuktiRoutine, m_ArkahaRoutineItem);
        }
    }
}
